<?php

namespace Biz\service\Userpenalty;

use Doraemon\service\Forbid;
use Doraemon\tools\Ip;


class StopComment
{
    public function handle( $data =[])
    {
        try {
            $uid = $data['uid'];
            if(empty($uid)) return false;
            $admin_id = $data['admin_id'];
            $time = $data['time'];
            $ip = Ip::getClientIp();
            if (empty($uid)) {
                throw new \Exception('用户uid不能为空');
            }

            if (empty($time)) {
                throw new \Exception('禁言时间不能为空');
            }
            Forbid::setForbid($uid, $time, $ip,$admin_id);
           return true;

        } catch (\Exception $e) {
            return false;
        }

    }

    public function cancle( $data = [])
    {
        try {
            $uid = $data['uid'];
            if(empty($uid)) return false;
            $adminId = $data['admin_id'];
            $ip = Ip::getClientIp();
            if (empty($uid)) {
                throw new \Exception('用户uid不能为空');
            }
            Forbid::delForbid($uid,$adminId,$ip,'解禁');
           return  true;
        } catch (\Exception $e) {
            return false;
        }
    }

}